import { fileURLToPath, URL } from 'node:url'


import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VantResolver(),ElementPlusResolver()],
    }),
    Components({
      resolvers: [VantResolver(),ElementPlusResolver()],
    }),
    // vueDevTools(),
  
  ],
  server: {
    proxy: {
      '/api': {
        target: 'https://fanyi-api.baidu.com',  // 后端服务器地址
        changeOrigin: true,              // 是否修改请求头中的Origin字段
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/other': {
        target: 'http://101.126.156.194:3000/',  // 第二个代理地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/other/, ''),
      },
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
